addpath('../lib');
addpath('../mockData');


disp('Start');
filename = 'data2.dat';
V = importdata(filename); %gera data

data = V(:, 2:end);
data = data + abs(min(min(data)));

waveList = V(:, 1)';
timeList = [17.514999	49.046001	80.578003	175.17101	490.48401	931.90601	1995.547	2795.5];

niter = 500;

S = svd(data)
R = numel(S(S > 0.4))

duomenys = data;

[W1 H1] = TNMF(duomenys, R, niter);

PlotW(waveList, W1, 'SpektrineInformacija');
PlotH(timeList, H1, 'TankiuKitimasLaike');
figure;
plot(waveList, W1);
PlotMain(waveList,timeList, duomenys, 'PradiniaiDuomenys');
PlotMain(waveList,timeList, W1*H1, 'IsskirtosInformacijosBendrasVaizdas');
PlotMain(waveList, timeList, duomenys - W1*H1, 'skirtumasNuoPradiniuDuomenu', 'norm', 0);
disp('Finished');
